<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
          name="viewport">
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <meta name="csrf-token" content="cPqshWzq8AP6CPB3WnTjWi7etMHthoseg6rFAYVE">
    <title>修改</title>
    <meta name="description" content="修改"/>
    <meta name="Keywords" content="修改"/>
    {include file="common/link" /}
    <style>
        .reward_text {
            text-align: right;
            padding-right: 15px;
        }
    </style>
</head>
<body class="body-1">
<div id="container">
    <div class="mui-bar-tab cart-btn-box centerflex line-top">
        <div class="total-price box-flex-1 text-l">
            <p>共<em class="selectedNum" >{$count}</em>件商品</p>
            <p class="total">合计：<span class="red actual_cost" >{$row.actual_cost}</span>元</p>
        </div>
        <a class="editsales" href="javascript:;" >修改</a>
    </div>
     
     <div class="mui-content">
<!--         <div class="receiving-address bgcolor-white mb10 arrow">-->
         <div class="receiving-address ">
             <a href="javascript:void (0)" class="highlight  select_adr">
                <h2 class="ft14 clearfix">
                    <span class="fl">{$contacts}</span>
                    <span class="fr">{$mobile}</span>
                </h2>
                <p class="ft13">
                    收货地址：{$address}
                 </p>
             </a>
         </div>
         <div class="home-link-box bgcolor-white">
             <a href="javascript:;">
                 <i class="iconfont icon-shop"></i>
            </a>
         </div>
         {volist name="list" id="vo"}
            <div class="order-pro-group bgcolor-white goodsdata ">
                <div class="order-pro-item order-pro-new-item centerflex line-top"><!---->
                    <div class="txt box-flex-1 setprice" data-id="{$vo.id}">
                        <h2 class="title">{$vo.title}</h2>
<!--                        <span class="red-price">¥<em class="pro-price">110.00</em></span>-->
                        <p class="clearfix">
                            <span class="attribute fl"><em>规格：{$vo.specs}</em></span>
                            <span class="num fr">×<em class="ft14 goods_num">{$vo.goods_num}</em></span>
                        </p>
                        <p>含税单价: <span class="ht_price">{$vo.ht_price}</span></p>
<!--                        <p>税点: <span class="tax">{$vo.tax}</span></p>-->
<!--                        <p>数量: <span class="goods_num">{$vo.goods_num}</span></p>-->
<!--                        <input type="text" placeholder="含税价格">-->
<!--                        <input type="text" placeholder="税点">-->
<!--                        <input type="text" placeholder="数量">-->
                    </div>
                </div>
            </div>
         {/volist}
         <div class="settlement-item centerflex bgcolor-white line-top">
             <label>税点</label>
             <input type="text" placeholder="在此输入税点" class="box-flex-1 tax" onkeyup="checkTaxFloat(this);" value="{$row.tax}">
         </div>
<!--         <div class="settlement-item centerflex bgcolor-white line-top"><label>运费</label>-->
<!--             <span class="red-price box-flex-1 reward_text"><em>免运费</em></span>-->
<!--         </div>-->
<!--         <div class="settlement-item centerflex bgcolor-white line-top"><label>小计</label>-->
<!--             <span class="red-price box-flex-1 reward_text">¥<em class="pro-price">{$row.actual_cost}</em></span>-->
<!--         </div>-->
         <div class="settlement-item centerflex bgcolor-white line-top">
             <label>买家留言</label>
             <input type="text" placeholder="在此输入留言内容" class="box-flex-1 explain" value="{$row.explain}">
         </div>
<!--         <div class="invoice-item bgcolor-white mt10">-->
<!--             <span class="check-box-tit">是否需要开发票</span>-->
<!--             <span class="fr"><label>-->
<!--                 <input type="radio" name="fapiao" value="1" class="newslist">是</label>-->
<!--                 <label><input type="radio" name="fapiao" value="0" class="newslist">否</label>-->
<!--             </span>-->
<!--         </div>-->
     </div>
{include file="common/left-nav" /}
{include file="common/script" /}
    <script src="__CDN__/assets/web/plugins/fastclick.js"></script>
<script src="__CDN__/assets/web/js/place.js"></script>
<!--<script src="__CDN__/assets/web/js/city.data3.js"></script>-->
<!--<script src="__CDN__/assets/web/plugins/mui.picker.min.js"></script>-->
<!--<script src="__CDN__/assets/web/plugins/mui.poppicker.js"></script>-->

</body>
</html>
<script>
    var that;
    $('.mui-content').on('click','.setprice',function () {
        layer.prompt({
            title: '设置金额',
//                    area: ['800px', '350px'] //自定义文本域宽高
        }, function(value, index, elem){
            var id = that.data('id')
            var goods_num=$('#goods_num').val()
            that.find('.ht_price').html(value)
            that.find('.goods_num').html(goods_num)
            layer.close(index);
            count()
        });
        var goods_num = $(this).find('.goods_num').html()
        var ht_price = $(this).find('.ht_price').html()
        that = $(this)
        $(".layui-layer-content").find('input').attr('placeholder','含税单价')
        $(".layui-layer-content").find('input').attr('value',ht_price)
        $(".layui-layer-content").append("<br/><input type=\"text\" id=\"goods_num\" class=\"layui-layer-input\" value=\""+goods_num+"\" placeholder=\"数量\"/>")
        $('.layui-layer-confirm').attr('style','display:none')
    })
    function count(){
        goods_num = 0;
        all_price = 0;
        $('.mui-content').find('.goodsdata').each(function () {
            goods_num+= $(this).find('.goods_num').html()*1
            all_price+= $(this).find('.ht_price').html()*$(this).find('.goods_num').html()
        })
        $('.selectedNum').html(goods_num)
        $('.actual_cost').html(all_price)
    }
    $('.editsales').click(function () {
        var datas = new Array();
        $('.mui-content').find('.order-pro-group').each(function () {
            console.log()
            var cat_id = $(this).find('.setprice').data('id')
            var goods_num = $(this).find('.goods_num').html()
            var ht_price = $(this).find('.ht_price').html()
            datas.push({id:cat_id,goods_num:goods_num,ht_price:ht_price})
        })


        var tax = $('.tax').val()
        if(tax <0 || tax ==''){
            layer.msg('税点必须填写')
            $('.tax').focus()
            return false
        }
        var explain = $('.explain').val()

        // console.log(datas)
        // console.log(tax)
        // console.log(explain)
        // console.log(explain)

        var url = "{$turl}"+'/web/sales/edit'+ location.search;
        $.post(url,{datas:datas,tax:tax,explain:explain},function (res) {
            layer.msg(res.msg)
            if(res.code == 1){
                setInterval(function () {
                    window.location.href = '/web/sales/index'
                },800)
            }
        })

    })
    function checkTaxFloat(obj) {
        obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
        if(obj.value >13){
            obj.value = 13;
        }
        var x = obj.value.indexOf('.') + 1;   //小数点的位置
        var y = obj.value.length;

        if(x>1 && (y-x) >0){
            if((y-x)>1){
                obj.value= parseFloat(obj.value).toFixed(1)
            }
        }
        if(obj.value.indexOf(".")< 0 && obj.value !=""){
            obj.value= parseFloat(obj.value)
        }
    }
</script>
<!---带扇形 不带footer->
